﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using JumpJump.Runtime;

namespace JumpJump.UI
{
    public class PiecesControl : RadioButton
    {
        private Piece _piece;
        public Piece Piece
        {
            get
            {
                return this._piece;
            }
            set
            {
                this._piece = value;
            }
        }

        public static readonly DependencyProperty PieceIDProperty
            = DependencyProperty.RegisterAttached(
            "PieceID",
            typeof(int),
            typeof(PiecesControl),
            new PropertyMetadata(-1));

        public int PieceID
        {
            get
            {
                return (int)GetValue(PieceIDProperty);
            }
            set
            {
                SetValue(PieceIDProperty, value);
            }
        }

        public static readonly DependencyProperty PlayerIDProperty
            = DependencyProperty.RegisterAttached(
            "PlayerID",
            typeof(int),
            typeof(PiecesControl),
            new PropertyMetadata(-1));

        public int PlayerID
        {
            get
            {
                return (int)GetValue(PlayerIDProperty);
            }
            set
            {
                SetValue(PlayerIDProperty, value);
            }
        }

        public static readonly DependencyProperty IsVisualPieceProperty
            = DependencyProperty.RegisterAttached(
            "IsVisualPiece",
            typeof(bool),
            typeof(PiecesControl),
            new PropertyMetadata(false));

        public bool IsVisualPiece
        {
            get
            {
                return (bool)GetValue(IsVisualPieceProperty);
            }
            set
            {
                SetValue(IsVisualPieceProperty, value);
            }
        }

        public static readonly DependencyProperty IsLastMoveProperty
            = DependencyProperty.RegisterAttached(
            "IsLastMove",
            typeof(bool),
            typeof(PiecesControl),
            new PropertyMetadata(false));

        public bool IsLastMove
        {
            get
            {
                return (bool)GetValue(IsLastMoveProperty);
            }
            set
            {
                SetValue(IsLastMoveProperty, value);
            }
        }



        protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
        {
            //base.OnMouseLeftButtonDown(e);
            if (this.IsChecked == true)
            {
                this.IsChecked = false;
            }
            else
            {
                this.IsChecked = true;
            }
        }
    }
}
